<html xmlns:th="http://www.thymeleaf.org" xmlns:x="http://www.w3.org/1999/html">

<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false" title="" style="overflow: hidden;padding: 3px;">
        <form id="adminEditForm" method="post">
            <div class="light-info" style="overflow: hidden;padding: 3px;">
                <div>密码不修改请留空。</div>
            </div>
            <table class="grid">
                <tr>
                    <td>登录名</td>
                    <td>
                        <input name="id" type="hidden" th:value="${admin.id}">
                        <input name="username" type="text" placeholder="请输入登录名称" class="easyui-validatebox" data-options="required:true" th:value="${admin.username}">
                    </td>
                    <td>姓名</td>
                    <td><input name="name" type="text" placeholder="请输入姓名" class="easyui-validatebox" data-options="required:true" th:value="${admin.name}"></td>
                </tr>
                <tr>
                    <td>电话</td>
                    <td>
                        <input type="text" name="phone" placeholder="请输入手机号" th:value="${admin.phone}" class="easyui-numberbox"/>
                    </td>
                    <td>邮箱</td>
                    <td>
                        <input type="text" name="email" placeholder="请输入邮箱" th:value="${admin.email}" class="easyui-validatebox" data-options="required:true,validType:'email'"/>
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="text" name="password"/></td>
                    <td>性别</td>
                    <td>
                        <x:select id="adminEditSex" name="sex" type="adminSex" class="easyui-combobox" data-options="width:160,height:29,editable:false,panelHeight:'auto'"/>
                    </td>
                </tr>
                <tr>
                    <td>年龄</td>
                    <td><input type="text" name="age" th:value="${admin.age}" class="easyui-numberbox"/></td>
                    <td>用户类型</td>
                    <td>
                        <x:select id="adminEditUserType" name="userType" type="adminType" class="easyui-combobox" data-options="width:160,height:29,editable:false,panelHeight:'auto'"/>
                    </td>
                </tr>
                <tr>
                    <td>部门</td>
                    <td><select id="adminEditorganizationId" name="organizationId" class="easyui-validatebox" data-options="width:160,height:29,required:true"></select></td>
                    <td>角色</td>
                    <td><input id="adminEditRoleIds" name="roleIds"/></td>
                </tr>
                <tr>
                    <td>是否锁定</td>
                    <td>
                        <x:select id="adminEditLocked" name="locked" type="adminLocked" class="easyui-combobox" data-options="width:160,height:29,editable:false,panelHeight:'auto'"/>
                    </td>
                    <td>用户状态</td>
                    <td>
                        <x:select id="adminEditStatus" name="status" type="dbStatus" class="easyui-combobox" data-options="width:160,height:29,editable:false,panelHeight:'auto'"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<script type="text/javascript" th:inline="javascript">
    $(function() {
        $('#adminEditorganizationId').combotree({
            url: basePath + '/organization/tree',
            parentField : 'pid',
            panelHeight : 'auto',
            value : '[[${admin.organizationId}]]'
        });

        $('#adminEditRoleIds').combotree({
            url: basePath + '/role/tree',
            parentField : 'pid',
            panelHeight : 'auto',
            multiple : true,
            required : true,
            cascadeCheck : false,
            value : [[${roleIds}]]
        });

        $('#adminEditForm').form({
            url : basePath + '/admin/edit',
            onSubmit : function() {
                progressLoad();
                var isValid = $(this).form('validate');
                if (!isValid) {
                    progressClose();
                }
                return isValid;
            },
            success : function(result) {
                progressClose();
                result = $.parseJSON(result);
                if (result.code === 1) {
                    parent.$.modalDialog.openner_dataGrid.datagrid('reload');
                    parent.$.modalDialog.handler.dialog('close');
                } else {
                    parent.$.messager.alert('错误', result.msg, 'error');
                }
            }
        });

        $("#adminEditSex").val('[[${admin.sex}]]');
        $("#adminEditUserType").val('[[${admin.userType}]]');
        $("#adminEditLocked").val('[[${admin.locked}]]');
        $("#adminEditStatus").val('[[${admin.status}]]');
    });
</script>
